package structs;

import binomial.BinomialDistribution;







public class CardProbability 
{
	private double prob_of_life;
	private double prob_of_Copa;
	private double prob_of_Basto;
	private double prob_of_Espada;
	private double prob_of_Oro;
	private double prob_of_not_life;

	private double prob_of_highCards;
	private double prob_of_midCards;
	private double prob_of_lowCards;

	private double prob_of_highLife;
	private double prob_of_midLife;
	private double prob_of_lowLife;

	private double prob_of_highCopa;
	private double prob_of_midCopa;
	private double prob_of_lowCopa;

	private double prob_of_highBasto;
	private double prob_of_midBasto;
	private double prob_of_lowBasto;

	private double prob_of_highEspada;
	private double prob_of_midEspada;
	private double prob_of_lowEspada;

	private double prob_of_highOro;
	private double prob_of_midOro;
	private double prob_of_lowOro;

	private double prob_of_higherHand1;
	private double prob_of_higherHand2;
	private double prob_of_higherHand3;

	private double prob_op_has_life;
	private double prob_part_has_life;

	private double prob_op_has__higherLife;
	private double prob_part_has_higherLife;

	private double prob_op_has_higherHand1;
	private double prob_op_has_higherHand2;
	private double prob_op_has_higherHand3;

	private double prob_part_has_higherHand1;
	private double prob_part_has_higherHand2;
	private double prob_part_has_higherHand3;

	public Game game;
	public DeckInformation deckInfo;
	public BinomialDistribution binomialDistPro;


	public CardProbability(Game game, DeckInformation deckDist){
		this.game = game;
		this.deckInfo = deckDist;
		this.prob_of_higherHand1= 0.0;
		this.prob_of_higherHand2= 0.0;
		this.prob_of_higherHand3= 0.0;
	}

	public void initialProbability()
	{
		prob_of_life = 1/4;
		prob_of_not_life = 3/4;

		prob_of_Copa = 1/4;
		prob_of_Basto = 1/4;
		prob_of_Espada = 1/4;
		prob_of_Oro = 1/4;

		prob_of_highCards = 1/5;
		prob_of_midCards = 3/10;
		prob_of_lowCards = 1/2;

		prob_of_highBasto = 1/20;
		prob_of_midBasto = 3/40;
		prob_of_lowBasto = 1/8;

		prob_of_highCopa = 1/20;
		prob_of_midCopa = 3/40;
		prob_of_lowCopa = 1/8;

		prob_of_highEspada = 1/20;
		prob_of_midEspada = 3/40;
		prob_of_lowEspada = 1/8;

		prob_of_highOro = 1/20;
		prob_of_midOro = 3/40;
		prob_of_lowOro = 1/8;


	}

	public void updateProbability()
	{
		prob_of_life = this.deckInfo.getLifeCards().size()/this.deckInfo.getCardNotSeen();
		prob_of_not_life = 1-prob_of_life;

		prob_of_Copa = this.deckInfo.getCopaCards().size()/this.deckInfo.getCardNotSeen();
		prob_of_Basto = this.deckInfo.getBastoCards().size()/this.deckInfo.getCardNotSeen();
		prob_of_Espada = this.deckInfo.getEspadaCards().size()/this.deckInfo.getCardNotSeen();
		prob_of_Oro = this.deckInfo.getOroCards().size()/this.deckInfo.getCardNotSeen();

		prob_of_highCards = (this.deckInfo.getOtherHighCards().size() + this.deckInfo.getHighLifeCards().size())/this.deckInfo.getCardNotSeen();
		prob_of_midCards = (this.deckInfo.getOtherMidCards().size() + this.deckInfo.getMidLifeCards().size())/this.deckInfo.getCardNotSeen();
		prob_of_lowCards = (this.deckInfo.getOtherLowCards().size() + this.deckInfo.getLowLifeCards().size())/this.deckInfo.getCardNotSeen();

		prob_of_highBasto = this.deckInfo.getHighBastoCards().size()/this.deckInfo.getCardNotSeen();
		prob_of_midBasto = this.deckInfo.getMidBastoCards().size()/this.deckInfo.getCardNotSeen();
		prob_of_lowBasto = this.deckInfo.getLowBastoCards().size()/this.deckInfo.getCardNotSeen();

		prob_of_highCopa = this.deckInfo.getHighCopaCards().size()/this.deckInfo.getCardNotSeen();
		prob_of_midCopa = this.deckInfo.getMidCopaCards().size()/this.deckInfo.getCardNotSeen();
		prob_of_lowCopa = this.deckInfo.getLowCopaCards().size()/this.deckInfo.getCardNotSeen();

		prob_of_highEspada = this.deckInfo.getHighEspadaCards().size()/this.deckInfo.getCardNotSeen();
		prob_of_midEspada = this.deckInfo.getMidEspadaCards().size()/this.deckInfo.getCardNotSeen();
		prob_of_lowEspada = this.deckInfo.getLowEspadaCards().size()/this.deckInfo.getCardNotSeen();

		prob_of_highOro = this.deckInfo.getHighOroCards().size()/this.deckInfo.getCardNotSeen();
		prob_of_midOro = this.deckInfo.getMidOroCards().size()/this.deckInfo.getCardNotSeen();
		prob_of_lowOro = this.deckInfo.getLowOroCards().size()/this.deckInfo.getCardNotSeen();

		prob_of_higherHand1 = this.deckInfo.getHigherHand1Cards()/this.deckInfo.getCardNotSeen();
		prob_of_higherHand2 = this.deckInfo.getHigherHand2Cards()/this.deckInfo.getCardNotSeen();
		prob_of_higherHand3 = this.deckInfo.getHigherHand3Cards()/this.deckInfo.getCardNotSeen();


		binomialProbability();
	}

	public void binomialProbability()
	{
//		binomialDistPro = new BinomialDistribution(6,prob_of_life);
//		prob_op_has_life = binomialDistPro.cumulativePlus(1);

		binomialDistPro = new BinomialDistribution(6,prob_of_higherHand1);
		prob_op_has_higherHand1 = binomialDistPro.cumulativePlus(1);

		binomialDistPro = new BinomialDistribution(6,prob_of_higherHand2);
		prob_op_has_higherHand2 = binomialDistPro.cumulativePlus(1);

		binomialDistPro = new BinomialDistribution(6,prob_of_higherHand3);
		prob_op_has_higherHand3 = binomialDistPro.cumulativePlus(1);

//		binomialDistPro = new BinomialDistribution(3,prob_of_life);
//		prob_part_has_life = binomialDistPro.cumulativePlus(1);

//		binomialDistPro = new BinomialDistribution(3,prob_of_higherHand1);
//		prob_part_has_higherHand1 = binomialDistPro.cumulativePlus(1);

//		binomialDistPro = new BinomialDistribution(3,prob_of_higherHand2);
//		prob_part_has_higherHand2 = binomialDistPro.cumulativePlus(1);

//		binomialDistPro = new BinomialDistribution(3,prob_of_higherHand3);
//		prob_part_has_higherHand3 = binomialDistPro.cumulativePlus(1);
	}

	public double getProbHigherHand(int j) 
	{	
		
		if(j == 0)
		{
			return this.prob_op_has_higherHand1;
		}

		else if(j == 1)
		{
			return this.prob_op_has_higherHand2;
		}

		else 
		{
			return this.prob_op_has_higherHand3;
		}
	}
}
